import { title } from "process";
import { createRouter,createWebHistory ,RouteRecordRaw} from "vue-router";

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect:'/index/goods'
  },
  {
    path: '/index',
    name: 'Index',
    component: ()=>import('../views/index/index.vue'),
    children:[{
      path:'goods',
      name:"goods",
      meta:{
        isShow:true,
        title:'商品列表'
      },
      component:()=>import('../views/goods/index.vue')
    },
    {
      path:'users',
      name:"users",
      meta:{
        isShow:true,
        title:'用户列表'
      },
      component:()=>import('../views/user/index.vue')
    }
    ,
    {
      path:'roles',
      name:"roles",
      meta:{
        isShow:true,
        title:'角色列表'
      },
      component:()=>import('../views/role/index.vue')
    }, {
      path:'authority',
      name:"authority",
      meta:{
        isShow:false,
        title:'权限列表'
      },
      component:()=>import('../views/authority/index.vue')
    }]
  },
  
  {
    path:'/login',
    name:'login', 
     component: () => import('../views/LoginView/index.vue')
  }
]
const router = createRouter({
  history: createWebHistory(),
  routes
})
// router.beforeEach((to,from,next)=>{
//   const token:string|null=localStorage.getItem('token')
//   if(!token&&to.path!=='/login'){
//     next('/login')
//   }else {
//     next()
//   }
// })
export default router